My full backup restore process is this:
Restoring backup files into a fresh install shouldn't take more than 15-30 minutes for all but the largest amount of data, which is typically media files. But everything else should be back so it feels like YOUR SYSTEM within 30 minutes with prior packages all freshly installed, assuming they are in the standard repos.
The trick for this is to .... backup the server and personal data (typically in HOME), back up system settings (files), backup personal settings (in HOME) and create a list of APT manually installed packages and back up that list.
Code:
$ apt-mark showmanual
is the command. Just redirect the output to a file.
At restore time,
- do a fresh install of the same OS (or a new release can work for about 90% of packages). The storage can be completely different, provided the same directory structure is maintained. EXT4 --> XFS --> ZFS - those changes are fine for the most part.
- restore selected system config files - not everything - but the specific files in /etc/ that you've modified (except the fstab). On a new system, get into the habit of adding a comment/tag to system settings that can easily be found during restore operations later.
Code:
# :RESTORE:
- restore all user's HOME directories. This will get the personal settings and data, typically. If the new OS is different, you may need to remove some settings for a few programs, but most will work (and self-upgrade for any new program versions).
- restore system data ... if you run a DBMS or web server, those files need to be put back where they were. Just drop them into the directory where they were with the same owner, group and permissions for the directories and all files.
- Feed the list of manually installed packages back into APT. When APT sees the prior settings from step 2, it will assume the package is being either reinstalled or upgraded and use those settings. It will see the data for those packages in the expected locations and perform any data migrations (almost always) that are required.
- When upgrading an OS, some programs will require manual changes to config files. Usually not the core files, but for files like sites-available/ and php.ini and other server-specific configs, expect those will need manual care and the admin will need to review the release changes for each server program version since the version on the old OS. Many admins will remember the changes when Apache moved from 2.2.x to 2.4.x. The same happens with php version and python version updates.
Rdiff-backup Restores:
sudo rdiff-backup --restore-as-of (timespec) \
{path-to-backup-area} {path-to-restore-locations}
- path-to-restore-locations will probably be /
- path-to-backup-area will probably be something like /media/Backups/{hostname}
- timespec is in the manpage TIME FORMATS section. A few examples:
- "now" (current backup)
- 3B ... means 3 Backups ago
- 34D (34 days ago)
- 2M (2 months ago, but "a month" is always 30 days)
- 1Y (1 yr ago)
- "YYYY/MM/DD", "YYYY-MM-DD", "MM/DD/YYYY", or "MM-DD-YYYY,"
Following those steps, takes about 15 minutes for each major part.
- 0-15m - Fresh OS install
- 15-30m - System and personal settings, along with non-media files ... so DBMS, websites, and personal documents
- 30-45m - Reinstall packages from the list of manually installed packages. It may not take 15 minutes - the time depends on how many manually installed packages are in the list. A few hundred are common.
So, in less than 45 min, we have a fresh install with all the critical programs, settings, data and files ready to go. All that is missing are media files - music, videos, which really should be stored on other storage devices anyways.
In short, if it takes a few hours to rebuild a system, you are doing it wrong.
2023-Backup-How-To
Last Update: 2023-02-09